#!/usr/bin/env python
# -*- coding: utf-8 -*-
import argparse
import os
import subprocess
import semantic_version


def main():
    parser = argparse.ArgumentParser(description='Bump to new version.')
    parser.add_argument('level',
                        help='Level of version to bump.',
                        choices=['major', 'minor', 'patch'])
    args = parser.parse_args()
    os.chdir(os.path.dirname(os.path.realpath(__file__)))
    with open('VERSION') as f:
        current_version = semantic_version.Version(f.readline().strip())
    if args.level == 'major':
        v = current_version.next_major()
    elif args.level == 'minor':
        v = current_version.next_minor()
    elif args.level == 'patch':
        v = current_version.next_patch()
    else:
        raise NotImplementedError('Level "{}" is not implemented.'.format(
            args.level))
    with open('VERSION', 'w') as f:
        f.write(str(v))


if __name__ == '__main__':
    main()
